<?php
/** ****************************************************************
 * This file is part of mod_smugmugbadge.
 *
 * mod_smugmugbadgeis free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.

 * mod_smugmugbadge is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with mod_smugmugbadge.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @package	mod_smugmugbadge
 * @copyright	Copyright (C) 2009  Cedric Walter - www.waltercedric.com - All rights reserved.
 *******************************************************************/

// Don't allow direct access to the module.
defined('_JEXEC') or die('Restricted access');

$Width       = $params->get('Width', '200');
$Height       = $params->get('Height', '200');
$autorepeat       = $params->get('autorepeat') == 1 ? 'true' : 'false';
$gridRows      = $params->get('gridRows', '3');
$gridColumns       = $params->get('gridColumns', '4');
$gridSpacing       = $params->get('gridSpacing', '1');
$gridDelay       = $params->get('gridDelay', '2');
$autoHideDelay       = $params->get('autoHideDelay', '4');
$slideshowDelay       = $params->get('slideshowDelay', '4');
$autostart       = $params->get('autostart') == 1 ? 'true' : 'false';
$useLargeImages       = $params->get('useLargeImages') == 1 ? 'true' : 'false';

$aboutlink       = $params->get('aboutlink', '');
$sharelink       = $params->get('sharelink', '');

$background       = $params->get('background', '000000');
$preloaderColor       = $params->get('preloaderColor', 'FFFFFF');
$preloaderGlow       = $params->get('preloaderGlow', 'FFFFFF');

$displayMode = $params->get('displayMode', 'full');
$forceSize = $params->get('forceSize', '');
$order = $params->get('order', 'norandom');

$gapImageTarget= '';

$AlbumID1       = $params->get('AlbumID1', '7421071');
$AlbumKey1       = $params->get('AlbumKey1', '53xgf');
$AlbumID2       = $params->get('AlbumID2', '7421071');
$AlbumKey2       = $params->get('AlbumKey2', '53xgf');
$AlbumID3       = $params->get('AlbumID3', '7421071');
$AlbumKey3       = $params->get('AlbumKey3', '53xgf');
$AlbumID4       = $params->get('AlbumID4', '7421071');
$AlbumKey4       = $params->get('AlbumKey4', '53xgf');

$count = strlen($AlbumID1) > 0 ? $count + 1 : $count;
$count = strlen($AlbumID2) > 0 ? $count + 1 : $count;
$count = strlen($AlbumID3) > 0 ? $count + 1 : $count;
$count = strlen($AlbumID4) > 0 ? $count + 1 : $count;

$index = rand(1, $count);

$albumid = 'AlbumID'.$index;
$albumkey = 'AlbumKey'.$index;

$albums='http%3A%2F%2Fapi.smugmug.com%2Fhack%2Ffeed.mg%3FType%3Dgallery%26Data%3D'.$$albumid.'_'.$$albumkey.'%26format%3Drss200%26Sandboxed%3D1';
?>

<div style="background: #000000;-moz-border-radius: .6em;-webkit-border-radius: .6em;overflow:hidden;text-align: center;padding-top:13px;width:220px;height:220px;margin:0 auto;">
<!-- module by Cedric Walter - http://www.waltercedric.com - copyright 2009 -->
<?php
$flashvars = 'autorepeat='.$autorepeat;
$flashvars .= '&amp;gridRows='.$gridRows;
$flashvars .= '&amp;gridColumns='.$gridColumns;
$flashvars .= '&amp;gridSpacing='.$gridSpacing;
$flashvars .= '&amp;gridDelay='.$gridDelay;
$flashvars .= '&amp;autoHideDelay='.$autoHideDelay;
$flashvars .= '&amp;slideshowDelay='.$slideshowDelay;
$flashvars .= '&amp;autostart='.$autostart;
$flashvars .= '&amp;aboutlink='.$aboutlink;
$flashvars .= '&amp;sharelink='.$sharelink;
$flashvars .= '&amp;background=%23'.$background;
$flashvars .= '&amp;forceSize='.$forceSize;
$flashvars .= '&amp;displayMode='.$displayMode;
$flashvars .= '&amp;useLargeImages='.$useLargeImages;
$flashvars .= '&amp;albums='.$albums;
$flashvars .= '&amp;gapImage=http%3A%2F%2Fphotos.smugmug.com%2Fimg%2Fbesocial%2Finvisible_filler.png';
$flashvars .= '&amp;gapImageTarget='.$gapImageTarget;
$flashvars .= '&amp;preloaderGlow=%23'.$preloaderGlow;
$flashvars .= '&amp;preloaderColor=%23'.$preloaderColor;
$flashvars .= '&amp;order='.$order;
$flashvars .= '&amp;width='.$Width;
$flashvars .= '&amp;height='.$Height;
$flashvars .= '&amp;BadgeHost=cdn.smugmug.com';
$flashvars .= '&amp;mode=box';
?>

<object type="application/x-shockwave-flash" data="http://cdn.smugmug.com/swfs/badge/flashbadge.swf" width="<?php echo $Width ?>" height="<?php echo $Height ?>" id="smugmugbadge">
<param name="movie" value="http://cdn.smugmug.com/swfs/badge/flashbadge.swf" />
<param name="flashvars" value="<?php echo $flashvars ?>" />
<param name="wmode" value="transparent">
</object>
<center><small><a href="http://www.waltercedric.com">smugmugbadge</a></small></center>
</div>
